﻿/* Pomoho UI - Manage */
/* Created By onemax 2008-10-24 11:41:42 */
Pui.manage.video = {
	videoId:0,
	//Ajaxurl:'',
	AddToCombo: function(Id){
		if($("#FloatDiv label").length<1){
			Pui.manage.MsgDiv(1,'错误：','您还没有加入过社团');
			return
		}	
		this.videoId=Id;	
		$('#FloatDiv').showDiv();
	},
	AddCombo: function(path){
		var arr=$(""+path+" input:checked").not(".all");
			var ids='';
			if(arr.length==0)
			{
				$("#Msg").html("错误：至少请选择一个社团");
				return
			}		
			for(var i=0;i<arr.length;i++){
				if (i == 0) {
					ids = arr.eq(i).attr("id")+"||||"+arr.eq(i).attr("name");
				}
				else{
					ids += '$$' + arr.eq(i).attr("id")+"||||"+arr.eq(i).attr("name");

				}
			}
			 //Pui.loadScript(this.Ajaxurl"?videoId="+Pui.manage.video.vedieoId+"+str="+ids);
			//alert(ids)
			//this.ShowCombo("123||||aaa$$12||||ggg");
			$('#FloatDiv').hideDiv();
			$(""+path+" input:checked").check("off");
			$('#FloatDiv').hideDiv('Pui.manage.video.init()');
			return ids;
	},
	ShowCombo:function(videos){
		var arr=videos.split('$$');
		var str='';
		var vId;
		
		for(var i=0;i<arr.length;i++){
			vId=arr[i].split('||||');
			str+='<div class="name"><a href="http://www.pomoho.com/combo/'+vId[0]+'" target="_blank" title="'+vId[1]+'">'+vId[1]+'</a></div>';
		}
		if(arr.length<3&&($("#FloatDiv label").length>=3)){
			str+='<div class="name"><a href="javascript:Pui.manage.video.AddToCombo('+this.videoId+')" title="">添加到社团</a></div>';
		}
		$("#Video_"+this.videoId+" .outer").html(str);
	},
	showTips:function(){
		if($('#Tab .s1').hasClass('ac')||$('#Tab .s2').hasClass('ac')){
		$('<div class="notes_tip">当您的视频转换失败或未通过审核,将不会出现在视频列表中</div>').appendTo('.tHead .t4')
		$('.tHead .t4').css('background','url(http://static01.pomoho.com/themes/manage/default/images/sound.gif) no-repeat 0 8px').mouseover(function(){$('.notes_tip').css('display','block');}).mouseout(function(){$('.notes_tip').css('display','none');});}
	},
	init:function(){
		$("#FloatDiv input:checkbox").check('off');
		$("#Msg").html("");
	},
	zz: function() {
		var tt=$('#Layout_2 .tList li');
		var dsdd=$('#Layout_2 .tList li .tBtna a')
		for(i=0;i<tt.length;i++){
			var v_vw = tt.eq(i).attr('id');
			var flvid= v_vw.replace('Video_','');
			gg();
		}
		function gg(){
			var urlParm = "";
			var htmlcode = '';
			var vTitle = encodeURIComponent($('title').html().replace(/(^\s*)|(\s*$)/g, ""));
			var vLink ='http://home.pomoho.com/' + _space_user.spaceUrl + '/' + flvid;
			var vContent = 'http://video.pomoho.com/swf/out_player.swf?flvid=' + flvid+"&outall=true";
			var vSource = encodeURIComponent('爆米花网');
			var vSourceUrl = encodeURIComponent('http://www.pomoho.com/');
			var s = '';
			s += '<div id="ZZ" class="inboxs" style="display:none;">';
			s += ' <div class="s1">';
			urlParm = "flvid";
			var htmlcode = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="480" height="396" id="object"><param name="allowScriptAccess" value="always" /><param name="allowFullScreen" value="true" /><param name="movie" value="'+vContent+'" /><embed src="'+vContent+'" quality="high" width="480" height="396" allowScriptAccess="always"/></object>';
			if (String(window.location).match(/http:\/\/video\.dvod.*/)) {
				s += '  此节目地址（URL）<br /><input type="text" class="url" value="http://video.dvod.com.cn/news/' + flvid + '.shtml" /><br />';
			} else {
				s += '  此节目地址（URL）<br /><input type="text" class="url" value="'+vLink+'" /><br />';
			}
			s += '  把播放器显示到个人空间或Blog<br /><input type="text" class="url" value="'+vContent+'" /><br />';
			s += '  HTML代码,适用于个人空间（或其他类型的Blog）<br /><input type="text" class="url" id="KongUrl" value="" /><br />';
			s += '  BBS代码<br /><input type="text" class="url" value="[flash]'+vContent+'[/flash]" />';
			s += ' </div>';
			s += '  <p><a href="javascript:void(0);" >关闭</a></p>';
			s += '</div>';
			$(s).appendTo($('#Layout_2 .cols_1 .tList li:eq('+i+')')).css({
				'z-index': '9999',
				'top': '-100px',
				'left': '300px'
			});
			$('.tList li').find('#KongUrl').eq(0).attr('value',htmlcode);
		}
    },
	Fksdh:function(){
		this.zz();
		var zss=$('.tList li .tBtna a');
		
		zss.click(function(){
			var _self=$(this);
			$(".inboxs").css({'display':'none'});
			_self.parents("li").find(".inboxs").slideDown('slow');
			this.blur();
			return false;
		})
		var zcz=$('.tList li').find("#ZZ p a");
		zcz.click(function(){
			var _se=$(this);
			_se.parent('p').parent('div#ZZ').slideUp('slow');
			return false;
		})
	}
};
/*未审核播放*/
function Yangmin(vSources){
    if(vSources=="")
    {
        return false;
    }
	var Bh=$('#B-Manage-VideoUpload').height();
	var Bw=$('#B-Manage-VideoUpload').width();
	var str = '';
	str += '<div id="zhezhao"></div>';
	str += ' <div id="Prompt" class="prompt">';
	str += '    <div class="">';
	str += '           <div class="close"><a href="javascript:void(0);" title="关闭"></a></div>';
	str += '      <div class="meat">';
	str +='           <script src="http://static.pomoho.com/scriptures/flashobject.js" language="javascript"></script>';
	str +='           <span id="PlayerZone"><embed height="496" width="580" wmode="transparent" allowscriptaccess="always" allowfullscreen="true" quality="high" bgcolor="#000000" name="player" id="player" src="http://video.pomoho.com/swf/player_no.swf?source='+vSources+'" type="application/x-shockwave-flash"></span>';
	str += '      </div>';
	str += '    </div>';
	str += '  </div>';
	$("body").prepend(str);
	$('#zhezhao').width(Bw);
	$('#zhezhao').height(Bh);
	resetBg();
	closeBg();
}
function getObjWh(obj){
	var st=document.documentElement.scrollTop;//滚动条距顶部的距离
	var sl=document.documentElement.scrollLeft;//滚动条距左边的距离
	var ch=document.documentElement.clientHeight;//屏幕的高度
	var cw=document.documentElement.clientWidth;//屏幕的宽度
	var objH=$("#"+obj).height();//浮动对象的高度
	var objW=$("#"+obj).width();//浮动对象的宽度
	var objT=Number(st)+(Number(ch)-Number(objH))/2;
	var objL=Number(sl)+(Number(cw)-Number(objW))/2;
	return objT+"|"+objL;
};
function resetBg(){
	var zhezhao=$("#zhezhao").css("display");
	if(zhezhao=="block"){
		var objV=getObjWh("Prompt");
		var tbT=objV.split("|")[0]+"px";
		var tbL=objV.split("|")[1]+"px";
		$("#Prompt").css({top:tbT,left:tbL});
	}	
};
//关闭灰色JS遮罩层和操作窗口
function closeBg(){
	$('#Prompt .close a').click(function(){
		$("#zhezhao").css("display","none");
		$("#Prompt").css("display","none");
	})
}



